package com.burntsky.xbmc.android;

import java.util.ArrayList;

import org.xbmc.android.remote.business.Command;
import org.xbmc.android.remote.business.ManagerFactory;
import org.xbmc.android.util.HostFactory;
import org.xbmc.api.business.INotifiableManager;
import org.xbmc.api.business.ITvShowManager;
import org.xbmc.api.business.IVideoManager;
import org.xbmc.api.object.Host;
import org.xbmc.api.object.Movie;
import org.xbmc.api.object.TvShow;
import org.xbmc.api.presentation.INotifiableController;

import android.content.Context;
import android.widget.Toast;


public class XbmcController implements INotifiableController {

	private Context _Context;
	
	public XbmcController(Context context)
	{
		this._Context = context;
		
		Host host = new Host();
		host.addr = "media-pc";
		host.port = Host.DEFAULT_HTTP_PORT;
		host.timeout = Host.DEFAULT_TIMEOUT;
		host.user = "media";
		host.pass = "111111";

    	HostFactory.host = host;
		
	}
	
	public Context getContext(){
		return this._Context;
	}
	
	public ArrayList<TvShow> GetTvShows()	{
		ITvShowManager tvMgr = ManagerFactory.getTvManager(this);
    	return tvMgr.getTvShows(this._Context);
	}
	
	public ArrayList<Movie> GetMovies(){
		IVideoManager mgr = ManagerFactory.getVideoManager(this);
		return mgr.getMovies(this._Context);
	}

	@Override
	public void onWrongConnectionState(int state, INotifiableManager manager,
			Command<?> source) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onError(Exception e) {
		// TODO Auto-generated method stub
		//Utils.Alert(this._Context, e.getMessage());
		Toast.makeText(this._Context, e.getMessage(), Toast.LENGTH_LONG).show();
	}

	@Override
	public void onMessage(String message) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void runOnUI(Runnable action) {
		// TODO Auto-generated method stub
		
	}
}
